#include<iostream>
using namespace std;
typedef long long LL;
LL n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		LL ans1 = 0;
		LL ans2 = 0;
		bool flag = 1;
		while (n) {
			if (flag) {
				if ((n&1)==0 && (n/2)%2==1&&n!=4) {
					ans1 += n / 2;
					n /= 2;
				}
				else if (n == 4) {
					ans1 += 3;
					break;
				}
				else {
					ans1++;
					n--;
				}
				flag = 0;
			}
			else {
				if ((n & 1)==0 && (n / 2) % 2 == 1 && n != 4) {
					ans2 += n / 2;
					n /= 2;
				}
				else if (n == 4) {
					ans1++;
					break;
				}
				else {
					ans2++;
					n--;
				}
				flag = 1;
			}
			//cout << "ans1==" << ans1 << endl;
			//cout << " n==" << n << endl;
		}
		cout <<ans1<< endl;
		//cout << ans2 << endl;
	}
	return 0;
}